package max.ta.stock.plot;

import java.io.IOException;
import java.util.List;

import max.ta.data.entity.StockQuote;
import max.ta.data.entity.StockValueType;
import max.ta.stock.DataLoader;
import max.ta.stock.indicator.Indicator;
import max.ta.stock.indicator.IndicatorValue;
import max.ta.stock.indicator.SMAIndicator;

import org.apache.log4j.Logger;

public class HighLowChartPlotterTest {

    private static final Logger logger = Logger.getLogger(HighLowChartPlotterTest.class);
    // -----------------------------------------
    private static final int WINDOW_SIZE = 20;
    private static final int DATA_SIZE = 120;
    private static final boolean OVERLAID = true;
    // -----------------------------------------
    private static final Indicator INDICATOR = new SMAIndicator(WINDOW_SIZE);
    private static final HighLowChartPlotter PLOTTER = new HighLowChartPlotter("IBM Stock");

    public static void main(final String[] args) throws IOException {
	List<StockQuote> quotes = DataLoader.load(DATA_SIZE);
	if (!OVERLAID) {
	    PLOTTER.plotSimple("IBM", quotes);
	} else {
	    List<IndicatorValue> values = INDICATOR.compute(quotes, StockValueType.CLOSE);
	    for (IndicatorValue v : values) {
		logger.debug(v);
	    }
	    PLOTTER.plotOverlaid("IBM", quotes, values);
	}
    }
}
